import 'package:base_flutter/base_flutter.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:ls_work/bad_event/ui/bad_event_list_page.dart';
import 'package:ls_work/doctor_patrol/view_model/create_doctor_patrol_view_model.dart';
import 'package:ls_work/res/gaps.dart';
import 'package:ls_work/util/ext_utils.dart';
import 'package:ls_work/widgets/common_widget.dart';
import 'package:ls_work/widgets/event_input_widget.dart';

import '../../res/colors.dart';
class CreateDoctorPatrolPage extends BaseStatefulMvvmWidget{
  @override
  State<StatefulWidget> createState() => _CreateDoctorPatrolState();

}

class _CreateDoctorPatrolState extends BaseMvvmState<CreateDoctorPatrolViewModel,CreateDoctorPatrolPage>{
  Widget get arrowRight => Icon(
    Icons.keyboard_arrow_right,
    size: 15,
    color: Colours.gray_99,
  );
  @override
  Widget? buildLoadingContentView() {
    var info = viewModel.data;
    return SingleChildScrollView(
      padding: EdgeInsets.symmetric(horizontal: 16),
      child: Column(
        children: [
          ...[
            TitleValueWidget(title: '长者姓名', value: viewModel.customerName,arrow: arrowRight).onTap((){
              viewModel.chooseElder();
            }),
            TitleValueWidget(title: '时间', value: info.finishTime,arrow: arrowRight).onTap((){
              viewModel.chooseTime();
            }),

            TitleInputWidget(title: '血压（收缩压mmHg）',text: info.healthReport?.high.toStringOrNull()??"",onChanged: (str){
              info.healthReport?.high = num.tryParse(str);
            },isRow: true,keyboardType: CommonInputType.number),

            TitleInputWidget(title: '血压（舒张压mmHg）',text: info.healthReport?.low.toStringOrNull()??"",onChanged: (str){
              info.healthReport?.low = num.tryParse(str);
            },isRow: true,keyboardType: CommonInputType.number,),

            TitleInputWidget(title: '脉搏（次/分）',text: info.healthReport?.pulseRate.toStringOrNull()??"",onChanged: (str){
              info.healthReport?.pulseRate = num.tryParse(str);
            },isRow: true,keyboardType: CommonInputType.number,),

            TitleInputWidget(title: '心率（次/分）',text: info.healthReport?.pulseRate.toStringOrNull()??"",onChanged: (str){
              info.healthReport?.pulseRate = num.tryParse(str);
            },isRow: true,keyboardType: CommonInputType.number,),

            TitleInputWidget(title: '血氧饱和度（%）',text: info.healthReport?.oxygen.toStringOrNull()??"",onChanged: (str){
              info.healthReport?.oxygen = num.tryParse(str);
            },isRow: true,keyboardType: CommonInputType.number,),

            TitleInputWidget(title: '体温（°c）',text: info.healthReport?.temperature.toStringOrNull()??"",onChanged: (str){
              info.healthReport?.temperature = num.tryParse(str);
            },isRow: true,keyboardType: CommonInputType.numberAndDecimal,),

            TitleInputWidget(title: '备注',text: info.remark??"",onChanged: (str){
              info.remark = str;
            },isRow: false,keyboardType: CommonInputType.text,),
          ].insertWidget(Gaps.dividerLine),

          SizedBox(height: 20,),
          TextButton(onPressed: (){
            viewModel.submitClick();
          }, child: CommonText('保存',textColor: Colors.white),style: badEventButtonStyle,)
        ],
      ),
    );
  }

  @override
  Widget buildRootView(BuildContext context, Widget loadingContentWidget) {
    return Scaffold(
      appBar: AppBar(
        title: Text('巡诊录入'),
      ),
      body: loadingContentWidget,
    );
  }

  @override
  CreateDoctorPatrolViewModel createViewModel() {
    return CreateDoctorPatrolViewModel(context);
  }

  @override
  void onRetryClick() {
  }

}